@extends('admin.layout.layout')
@section('content') 
<div class="row"> 
    <div class="col-lg-12">
        <h1 class="page-header">相册管理</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>  
<div class="panel-body">
    <div class="dataTable_wrapper">
        <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
        <div class="row">
    <form action="{{url('/admin/photo/photo')}}" medth="get">
        <div class="col-sm-6">
        <div class="dataTables_length" id="dataTables-example_length">
        <label>查看
            <select name="num" aria-controls="dataTables-example" class="form-control input-sm">
                <option value="5">5</option>
            </select>行</label>
        </div>
        </div>

        <div class="col-sm-6">
        <div id="dataTables-example_filter" class="dataTables_filter">
        <label>
            用户名:<input name="keywords" class="form-control input-sm" type="search"/>
        </label>
        <button class="btn btn-primary">查询</button>
        </div>
        </div>
    </form>
        </div>
        <div class="row">
        <div class="col-sm-12">
        <table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
            <thead>
                <tr role="row"><th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">ID</th>
                <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">用户ID</th>
                <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">相册名</th>
                <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">图片名</th>
                <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending">路径</th>
                <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">操作</th></tr>
            </thead>
        <tbody>  
        @foreach($res as $k=>$v)
           <tr role="row" class="gradeA odd sid"> 
            <td class="sorting_1 sid">{{$v->id}}</td> 
            <td>{{$v->uid}}</td> 
            <td class="center">{{$v->pid}}</td> 
            <td class="center">{{$v->pname}}</td> 
            <td class="center">{{$v->path}}</td> 
            <td class="center">
            <a class="fa fa-trash-o delete">删除</a>
            |
            <a href="{{url('/admin/photo/edit',['id'=>$v->id])}}" class="fa fa-wrench">修改</a>
            </td> 
           </tr>
        @endforeach
        </tbody>
        </table>
        </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="dataTables_info" id="dataTables-example_info" role="status" aria-live="polite"></div>
            </div>
            <div class="col-sm-6">
                <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
                   <?php echo $res->appends(['sort' => 'votes'])->render(); ?>
                </div>
            </div>
        </div>
        </div>
    </div>
</div>
@endsection
@section('myjs')
    <script type="text/javascript">
        $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $('.delete').click(function()
        {
            var id = $(this).parents('tr').find('.sid').html();
            var dd = $(this);
            // 发送ajax
            $.post('/admin/photo/delete',{id:id},function(data)
            {
                if(data == 1)
                {
                   dd.parents('tr').remove();
                }else{
                    alert('失败')
                }
            })

            return false;
        })
    </script>
@endsection